package com.aerfafish.spider.neo4j.repository;

import com.aerfafish.spider.neo4j.dao.FundValue;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;

/**
 * @author aerfafish
 * @date 2021/4/21 6:03 下午
 */
public interface FundValueRepository extends Neo4jRepository<FundValue, Long> {

    @Query("merge (fund:Fund{code:$fundCode}) " +
            "merge (date:Date{date: $date}) " +
            "merge p = (fund)-[r:FUND_VALUE]->(date) " +
            "set r.averageValue=$averageValue, r.accumulatedValue=$accumulatedValue, " +
            "r.dailyGrowthRate=$dailyGrowthRate, r.subscriptionStatus=$subscriptionStatus, " +
            "r.redemptionStatus=$redemptionStatus")
    void save(@Param("fundCode") String fundCode,
              @Param("date") String date,
              @Param("averageValue") Float averageValue,
              @Param("accumulatedValue") Float accumulatedValue,
              @Param("dailyGrowthRate") Float dailyGrowthRate,
              @Param("subscriptionStatus") String subscriptionStatus,
              @Param("redemptionStatus") String redemptionStatus);

}
